package org.huawei260.TiKu.ODsuanfa;

/**
 * @Author: qingle
 * @Date: 2024/10/28-16:11
 * @Description: 3103 【贪心】2024D-分割均衡字符串
 * @version: 1.0
 */
import java.util.Scanner;
public class D_2024D_3103__贪心_分割均衡字符串 {

//	public class Main {
		public static void main(String[] args) {
			Scanner sc = new Scanner(System.in);

			String s = sc.nextLine();

			int countX = 0;
			int countY = 0;

			int ans = 0;

			for (int i = 0; i < s.length(); i++) {
				if (s.charAt(i) == 'X') {
					countX++;
				} else {
					countY++;
				}

				if (countX == countY) {
					ans++;
				}
			}

			System.out.println(ans);
		}
	}
